package com.handinglian.employee.service;


import com.github.pagehelper.PageInfo;
import com.handinglian.common.dto.ResultData;
import com.handinglian.employee.dto.*;
import com.handinglian.employee.entity.UserInfo;
import com.handinglian.employee.param.*;
import com.handinglian.system.entity.Permission;
import org.dom4j.DocumentException;
import org.springframework.ui.ModelMap;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Future;

public interface UserInfoService {
    /**
    * 创建用户并分配分机，
    * @author pxl
    * @param userCreateParam
    * @return int
    * @date 2019/8/13 14:46
    */
    ResultData createUserInfo(UserCreateParam userCreateParam) throws IOException, DocumentException;

    int deleteUserInfo(Integer userId) throws IOException, DocumentException;

    UserInfoDto loadUserInfo(Integer userId);

    UserInfo get(Integer userId);

    SystemUserInfoDto loadSystemUserInfo(Integer userId);

    int updateUserInfo(UserUpdateParam userUpdateParam);

    int updateUserInfo(UserInfo userInfo);

    /**
    * 更新系统用户
    * @author pxl
    * @param systemUserParam
    * @return int
    * @date 2019/8/16 15:59
    */
    int updateSystemUser(SystemUserParam systemUserParam);

    /**
    * 创建系统用户
    * @author pxl
    * @param systemUserParam
    * @return int
    * @date 2019/9/4 13:35
    */
    int createSystemUser(SystemUserParam systemUserParam);

    int deleteSystemUser(Integer userId);


    /**
     * 恢复删除的中控主机,返回 1 则说明恢复用户分配分机成功，返回 2 则说明恢复用户成功，分配分机失败(分机不足)
     * @author pxl
     * @param jobNum
     * @return int
     * @date 2019/6/3 17:56
     */
    int recoverUserInfo(String jobNum) throws IOException, DocumentException;

    /**
     * 查询被删除的中控主机
     * @author pxl
     * @param jobNum 工号
     * @return com.handinglian.contentunion.entity.UserInfo
     * @date 2019/6/3 10:49
     */
    UserInfo loadInvalidUserInfo(String jobNum);

    /**
     * 分页查询中控主机列表
     * @author pxl
     * @param nameOrJobNumOrPhone
     * @param departmentName
     * @param pageIndex
     * @param pageSize
     * @return com.github.pagehelper.PageInfo<com.handinglian.contentunion.entity.UserInfo>
     * @date 2019/6/3 10:48
     */
    PageInfo<UserInfoDto> inquireUserInfoPageList(Integer userId, String nameOrJobNumOrPhone, String departmentName, String sexs, String phonePermissions, Integer pageIndex, Integer pageSize);

    PageInfo<SystemUserInfoDto> inquireSystemUserInfoPageList(Integer userId, String nameOrJobNumOrPhone, String loginStates, Integer pageIndex, Integer pageSize);

    /**
    * 查询数据库中已存在的工号
    * @author pxl
    * @param jobNumList
    * @return java.util.List<com.handinglian.employee.entity.UserInfo>
    * @date 2019/8/9 15:25
    */
    List<String> inquireUserInfoByJobNum(List<String> jobNumList);

    ImportUserDto importUserTemplateExcel(ModelMap map, HttpServletRequest request, HttpServletResponse response, MultipartFile file, Integer flag) throws Exception;

    List<Permission> inquirePermissionList(String jobNum);

    UserInfoDetailDto loadUserDetailByJobNum(String jobNum);

    UserInfo loadUserByJobNum(String jobNum);

    ExtensionDto loadExtensionByJobNum(String jobNum);

    List<UserInfoDto> inquireUserInfoByDepartmentId(Integer departmentId, String nameOrPhone);

    /**
    * 获取该部门和其子部门下的员工信息
    * @author pxl
    * @param departmentId
    * @return java.util.List<com.handinglian.employee.entity.UserInfo>
    * @date 2019/10/8 10:59
    */
    List<UserInfo> listSubByDepartmentId(Integer departmentId);

    int updatePassword(UpdatePasswordParam updatePasswordParam);

    String uploadHeadImage(MultipartFile file, Integer userId);

    void downloadHeadImage(HttpServletResponse response, String fileUuid);

    List<UserInfo> inquireUserIdByJobNum(Collection<String> jobNumCollection);

    int resetPassword(Integer userId);

    /**
    * 更新登录装填
    * @author pxl
    * @param loginStateParam 1管理端开启登录 0管理端禁用登录
    * @return int
    * @date 2019/9/4 11:10
    */
    int updateLoginState(LoginStateUpdateParam loginStateParam);

    Future<Integer> count();

    Future<Integer> countSystemUser();

    List<UserInfo> list(List<Integer> departmentIds);

    List<String> findPushIdByJobNum(String jobNum);

    int updatePushIdByJobNum(String updatedPushId, String jobNum);

    UserInfo get(String jobNum, String pushId);

    List<UserInfoDto> list();

    void pushAll() throws IOException;
}
